package com.xiongjie.base;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
import io.vertx.ext.web.Router;

public class HelloVertx extends AbstractVerticle {

    @Override
    public void start(Future<Void> f) throws Exception {
        //创建http服务端
        vertx.createHttpServer()
            .requestHandler(req -> {
                req.response().end("Hello Vert.x");
                System.out.println("hello");
            })
            .listen(8888, result -> {
                if (result.succeeded()) {
                    System.out.println("有请求："+result.toString());
                    f.complete();
                } else {
                    System.out.println("请求失败："+result.toString());
                    f.fail(result.cause());
                }
            });
    }
}
